package com.trkj.controller;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.trkj.pojos.CcArrange;
import com.trkj.pojos.CcScheduledetail;
import com.trkj.pojos.CcSunmoney;
import com.trkj.pojos.CcSurgery;
import com.trkj.pojos.Tbstaff;
import com.trkj.service.CcArrangeService;
import com.trkj.vo.CcArrangeScheduledetailVo;
import com.trkj.vo.CcArrangeVo;
import com.trkj.vo.CcHospCheckVo;
import com.trkj.vo.Result;

@Controller
public class CcArrangeController {
	@Autowired
	private CcArrangeService carraService;
	@RequestMapping("/tocc_arrange")
	public String tocc_arrange(){
		return "cc_arrange";
	}
	@RequestMapping("/tocc_text")
	public String tocc_text(){
		return "cc_text";
	}
	@RequestMapping("/tocc_queryAllCcArrange")
	public @ResponseBody Map<String,Object> queryAllCA(int page,int rows,String pdid){
		return carraService.findByAllCcArrange(page, rows,pdid);
	}
	@RequestMapping("/tocc_queryfindByastate")
	public @ResponseBody List<CcArrangeVo> findByastate(String pdid){
		return carraService.findByastate(pdid);
	}
	@RequestMapping("/tocc_queryfindBypatientName")
	public @ResponseBody List<CcArrangeVo> findBypatientName(String pdid,String pname){
		return carraService.qureBypatientName(pname, new BigDecimal(pdid));
	}
	@RequestMapping("/tocc_queryfindByStaffName")
	public @ResponseBody List<CcArrangeVo> findByStaffName(String pdid,String sname){
		return carraService.findByadoctoridOrarrd(new BigDecimal(pdid), sname);
	}
	@RequestMapping("/tocc_queryfindByStaffname")
	public @ResponseBody List<CcArrangeVo> findByStaffName2(String pdid,String sname){
		return carraService.findByadoctoridOrarrd2(new BigDecimal(pdid),sname);
	}
	@RequestMapping("/tocc_queryAllCcSunmoney")
	public @ResponseBody List<CcSunmoney> queryAllCcSunmoney(){
		return carraService.queryAllCcSunmoney();
	}
	@RequestMapping("/tocc_queryAllCcSurgery")
	public @ResponseBody List<CcSurgery> queryAllCcSurgery(){
		return carraService.queryAllCcSurgery();
	}
	@RequestMapping("/tocc_qureyBypostNo")
	public @ResponseBody List<Tbstaff> qureyBypostNo(String postNo){
		return carraService.qureyBypostNo(postNo);
	}
	@RequestMapping("/tocc_addCcArrangeScheduledetail")
	public @ResponseBody Result addCcArrangeScheduledetail(CcArrangeScheduledetailVo ccArrsdd,String arrange_id){
		if(ccArrsdd !=null){
			if(arrange_id.length()>0){
				ccArrsdd.getArrange().setArrangeid(Long.parseLong(arrange_id));
			}
			carraService.addCcScheduledetail(ccArrsdd);
			return  new Result(true,"操作成功！");
		}else{
			return  new Result(false,"操作失败！");
		}
	}
	@RequestMapping("/dellistCcArrange")
	public @ResponseBody Result delNewCcArrange(Long[] list){
		if(list.length>0){
			carraService.calCcArrange(list);
			return new Result(true, "取消成功！");		
		}else{
			return new Result(true, "所选的数据包含不符合要求的数据！");		
		}
	}
	@RequestMapping("/oklistCcArrange")
	public @ResponseBody Result okNewCcArrange(Long[] list){
		if(list.length>0){
			carraService.okCcArrange(list);
			return new Result(true, "处理成功！");		
		}else{
			return new Result(true, "处理失败！");		
		}
	}
	@RequestMapping("/tocc_qureyByschId")
	public @ResponseBody List<CcScheduledetail> qureyByschId(String schId){
		return carraService.qureyByschId(schId);
	}
	@RequestMapping("/tocc_queryOneByCcArrangeId")
	public @ResponseBody CcArrange queryOneById(long id){
		return carraService.queryOneById(id);
	}
}
